
<style type="text/css">
.button{background:url(images/left-menu-li.gif) repeat-x left top #F1F6F9; border:1px solid #318DAC; font-weight:bold; padding:2px 5px; font-weight:lighter; color:#318DAC; vertical-align:middle; -moz-border-radius:3px; -webkit-border-radius:3px; margin:auto 5px}
.center{text-align:center;}
.product_op{height:30px;}
.product_op span{cursor:pointer;}
.packageTips,.validateTips,.batchAddTips{color:red;line-height:25px;}
.height25 td{padding: 2px 5px;}
</style>

<style type="text/css">
div#add{
	text-align:center;
}
div.info{
	text-align:left;
}
div.item{
	margin-bottom: 12px;
}
input.text {
    height: 22px;    
    margin-left: 8px;
}
span.text{
	margin-left: 8px;
}
span.userInfoLeft{
	display:block;
	float:left;
	width:100px;
}
.myTab table td {
    border: 0 none;
    text-align: left;
}
.err{color:red;}
.err td{color:red;}
.userInfoRight a{color:#318DAC;}
.pagination input{display:none;}
</style>

<div id="right_confirm" style="display: none;"  title="<{$lang.tip}><{$lang.msg}>">
	
</div>

<div id="alert_msg" style="display: none;" title="<{$lang.tip}><{$lang.msg}>">
	<p style="font-size: 14px;">
	
	</p>
</div>
<div id="batchAdd" title="<{$lang.batch}><{$lang.add}><{$lang.product}>"> 
	<div class="info">
		<div class="batchAddTips"></div>
		<h3>测试<{$lang.function}>，<{$lang.do_not}>尝试</h3>		
		<form id="uploadForm" enctype="multipart/form-data" action="/shipping/ship-price/upload/ajax/1" method="post">
			<div class="  item">
				<select  id="type" name="type" >
					<option value="ship_price" <{if $op_type=="ship_price"}>selected<{/if}>><{$lang.shipping}><{$lang.price}>表</option>
					<option value="ship_type_country_map" <{if $op_type=="ship_type_country_map"}>selected<{/if}>><{$lang.zone}><{$lang.shipping_method}>对照表</option>
				</select>
				<span class="userInfoLeft"><{$lang.pls}><{$lang.file}>：</span>
				<span class="userInfoRight">
					<input type="file" name="productFile">支持.xls,.csv<{$lang.file}>
					<input type="submit" value="上传" name="sbt" id="batchAddBtn" class='button' onclick="loading();">
				</span>
				<span class="userInfoRight err" style="">
					<{$msg}>
				</span>
			</div>
			<div class="  item">				
				<span class="userInfoLeft">&nbsp;</span>
				<span class="userInfoRight">
					模板<{$lang.file}>：
					<a href='/images/ship_price.xls'><{$lang.shipping}><{$lang.price}>表</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a href='/images/ship_type_country_map.xls'><{$lang.zone}><{$lang.shipping_method}>对照表</a>
				</span>
			</div>
			<div class="  item">				
				<span class="userInfoLeft">&nbsp;</span>
				<span class="userInfoRight">
					注意：
					1、每次上传的<{$lang.file}> ，只能包含一种<{$lang.shipping_method}>。2、 模板<{$lang.file}>表格首行不能<{$lang.edit}>
				</span>
			</div>
		</form>
	
	</div>
</div>

<{if isset($list)&&isset($op_type)&&$op_type=="ship_price"&&$err==""}>
<script>	
	loading();
	var json = <{$json}>;
	$(function(){	
		items_per_page = 30;
		var num_entries = json.length;
		// <{$lang.create}>分页
		$(".pagination").pagination(num_entries, {				
			items_per_page:items_per_page,		
			callback: pageselectCallback,
			perpage_text:"",
			total_text:"共"
		});
		 
		function pageselectCallback(page_index){			
			var html ="";
			$.each(json,function(key,val){
				if((page_index)*items_per_page<=key&&key<(page_index+1)*items_per_page){
					html += "<tr class='"+val.cls+"'>";
					if(val.status==1){
					
						html += "<td>"+(key+1)+"</td>";
						html += "<td>"+val.sp_weight+"<input type='hidden' name='row["+key+"][sp_weight]' value='"+val.sp_weight+"'/></td>";
						html += "<td>"+val.sp_price+"<input type='hidden' name='row["+key+"][sp_price]' value='"+val.sp_price+"'/></td>";
						html += "<td>"+val.zone+"<input type='hidden' name='row["+key+"][zone]' value='"+val.zone+"'/></td>";
						html += "<td>"+val.ship_type+"<input type='hidden' name='row["+key+"][ship_type]' value='"+val.ship_type+"'/></td>";
						html += "<td>"+val.fee_type+"<input type='hidden' name='row["+key+"][fee_type]' value='"+val.fee_type+"'/></td> ";
						html += "<td>"+val.currency_code+"<input type='hidden' name='row["+key+"][currency_code]' value='"+val.currency_code+"'/></td>";
					}else{
						html += "<td>"+(key+1)+"</td>";
						html += "<td>"+val.weight+"</td>";
						html += "<td>"+val.price+"</td>";
						html += "<td>"+val.zone+"</td>";
						html += "<td>"+val.ship_type+"</td>";
						html += "<td>"+val.fee_type+"</td> ";
						html += "<td>"+val.currency_code+"</td>";
					}	        
					html += "</tr>";
				}
			});
			//alert(html);
			$("#list").html(html);
			closeLoading();
			return false;
		}

		pageselectCallback(0);
		
		$("#right_confirm").dialog({
			autoOpen : false,
			width : 400,
			modal : true,
			show : "slide",
			buttons : {
				'<{$lang.ok}>' : function() {
					//$("#batchAdd").click();
					$(this).dialog('close');
					//loading();
					//$("#batchAddForm").submit();
				},
				'<{$lang.cancel}>' : function() {
					$(this).dialog('close');
				}
			}
		});
		$("#batchAddButton").click(function(){			
			$("#right_confirm").html("您<{$lang.confirm}>清除 <b>"+$("#ship_type").val()+"</b> 老的<{$lang.shipping}><{$lang.price}>表,导入<{$lang.list}>中的<{$lang.shipping}><{$lang.price}>表？？");
			$("#right_confirm").dialog("open");
		});
	});	
</script>
<form action="/shipping/ship-price/batch-add" method="post" id="batchAddForm">
<div class="width100  product_op" style="padding:10px  10px;">	
	<input type="hidden" name='op_type' value="ship_price">	
	<{$lang.warehouse}>：
	<select  id="warehouse_id" name="warehouse_id" >
       <option value="1"><{$lang.warehouse}>1</option>
	   <option value="2"><{$lang.warehouse}>2</option>
    </select>
	<{$lang.shipping_method}>：<select  id="ship_type" name="ship_type" >
       
		<{foreach from=$shipType item=obj key=key name=obj}>
        	<option value="<{$obj.st_code}>" <{if $selectShipType==$obj.st_code}>selected<{/if}>><{$obj.st_code}></option>			
		<{/foreach}>
    </select>
	<input class="button" type="button" value="<{$lang.batch}><{$lang.add}>"  id="batchAddButton"  >
	<input class="button" type="submit" value="<{$lang.batch}><{$lang.add}>"  id="batchAdd"  style='display:none;'>&nbsp;&nbsp;
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="myTab">	
	<thead><tr>
    	<th><{$lang.No}></th>
    	<th><{$lang.weight}></th>
    	<th><{$lang.price}></th>
   		<th><{$lang.zone}></th>
    	<th><{$lang.shipping_method}></th>
        <th>费用<{$lang.type}></th> 
        <th><{$lang.currency}></th>
	</tr></thead>
    
	<tbody id="list">
		
	</tbody>
	
</table>

</form>
<div class="pagination"></div>
<{/if}>


<{if isset($list)&&isset($op_type)&&$op_type=="ship_type_country_map"&&$err==""}>
<script>
	loading();
	var json = <{$json}>;
	$(function(){	
		items_per_page = 30;
		var num_entries = json.length;
		// <{$lang.create}>分页
		$(".pagination").pagination(num_entries, {				
			items_per_page:items_per_page,		
			callback: pageselectCallback,
			perpage_text:"",
			total_text:"共"
		});
		 
		function pageselectCallback(page_index){			
			var html ="";
			$.each(json,function(key,val){
				if((page_index)*items_per_page<=key&&key<(page_index+1)*items_per_page){
					html += "<tr class='"+val.cls+"'>";
					if(val.status==1){					
						html += "<td>"+(key+1)+"</td>";
						html += "<td>"+val.country_code+"<input type='hidden' name='row["+key+"][country_code]' value='"+val.country_code+"'/></td>";
						html += "<td>"+val.stcm_area+"<input type='hidden' name='row["+key+"][stcm_area]' value='"+val.stcm_area+"'/></td>";
						html += "<td>"+val.ship_type+"<input type='hidden' name='row["+key+"][ship_type]' value='"+val.ship_type+"'/></td>";
					}else{
						html += "<td>"+(key+1)+"</td>";
						html += "<td>"+val.country_code+"</td>";
						html += "<td>"+val.stcm_area+"</td>";
						html += "<td>"+val.ship_type+"</td>";
					}	        
					html += "</tr>";
				}
			});
			//alert(html);
			$("#list").html(html);
			closeLoading();
			return false;
		}
	
		pageselectCallback(0);
		$("#right_confirm").dialog({
			autoOpen : false,
			width : 400,
			modal : true,
			show : "slide",
			buttons : {
				'<{$lang.ok}>' : function() {
					//$("#batchAdd").click();
					$(this).dialog('close');
					//loading();
					//$("#batchAddForm").submit();
				},
				'<{$lang.cancel}>' : function() {
					$(this).dialog('close');
				}
			}
		});
		$("#batchAddButton").click(function(){			
			$("#right_confirm").html("您<{$lang.confirm}>清除 <b>"+$("#ship_type").val()+"</b> 老的<{$lang.zone}><{$lang.shipping_method}>对照表,导入<{$lang.list}>中的<{$lang.zone}><{$lang.shipping_method}>对照表？？");
			$("#right_confirm").dialog("open");
		});
		
	});	
</script>
<form action="/shipping/ship-price/batch-add" method="post" id="batchAddForm">
<div class="width100  product_op" style="padding:10px  10px;">	
	<input type="hidden" name='op_type' value="ship_type_country_map">	
	<{$lang.shipping_method}>：
	<select  id="ship_type" name="ship_type" >       
		<{foreach from=$shipType item=obj key=key name=obj}>
        	<option value="<{$obj.st_code}>" <{if $selectShipType==$obj.st_code}>selected<{/if}>><{$obj.st_code}></option>			
		<{/foreach}>
    </select>
	<input class="button" type="button" value="<{$lang.batch}><{$lang.add}>"  id="batchAddButton"  >
	<input class="button" type="submit" value="<{$lang.batch}><{$lang.add}>"  id="batchAdd"  style='display:none;'>&nbsp;&nbsp;
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="myTab">	
	<thead><tr>
    	<th><{$lang.No}></th>
    	<th><{$lang.country}><{$lang.code}></th>
    	<th><{$lang.shipping}><{$lang.zone}></th>
   		<th><{$lang.shipping_method}></th>
	</tr></thead>
    
	<tbody id="list">
		
	</tbody>
	
</table>

</form>
<div class="pagination"></div>
<{/if}>